package com.h2cloud;

/**
 * @Package: com.h2cloud
 * @ClassName: EmailValidatorTest
 * @Author: wulongkai
 * @CreateTime: 2024/8/16 15:31
 * @Description:
 */
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class EmailValidatorTest {
    public static void main(String[] args) throws InterruptedException {
        ExecutorService executor = Executors.newFixedThreadPool(10); // 创建一个线程池

        // 测试的电子邮件列表
        String[] testEmails = {
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com",
                "test@example.com",
                "invalid-email",
                "another.test@domain.co",
                "user@subdomain.domain.com",
                "user@domain",
                "@domain.com",
                "user@domain..com"
        };

        // 提交任务
        for (String email : testEmails) {
            executor.submit(() -> {
                boolean result = EmailValidator.isValidEmail(email);
                System.out.println(email + " is valid: " + result);
            });
        }

        // 关闭线程池并等待完成
        executor.shutdown();
        executor.awaitTermination(1, TimeUnit.MINUTES);
    }
}

